<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head th:include="inc/home::header">
</head>
<link type="text/css" th:href="@{/css/content.css}" rel="stylesheet" />
<body>
	<!--返回-->
	<div class="back" onclick="loadPage('/wxjl')">
		<img src="images/back.png" />
	</div>
	<div class="head-top">
		<div th:include="header :: header"></div>
	</div>

	<div class="header-title">
		<span th:text="${title}">添加维修记录</span>
	</div>
	<div class="spare-a">
		<div class="save-bg">
			<a class="spare-tj" onclick="Save()">保 存</a>
		</div>
		<div class="spare-add">

			<form id="userGroupForm">

				<input type="text" readonly="readonly" style="display: none" name="id" />
				<ul>
					<li>
						<div class="spare-addl">编号：</div>
						<div class="spare-addr">
							<input type="text" class="spare-add-input" id="recordNo"
								name="recordNo" />
						</div>
					</li>
					<li>
						<div class="spare-addl">任务：</div>
						<div class="spare-addr">
							<input type="text" id="planId" name="planId" readonly="readonly" style="display: none"/>
							<input type="text" id="planName" name="planName" class="spare-add-inputa" />
							<a onclick="selectPlan()" class="spare-tj" style="float: right">计划任务</a>
						</div>
					</li>
					<li>
						<div class="spare-addl">维修日期：</div>
						<div class="spare-addr">
							<input type="text" id="maintDate" name="maintDate"
								class="spare-add-input" onclick="laydate()" />
						</div>
					</li>
					<li>
						<div class="spare-addl">维修用时：</div>
						<div class="spare-addr">
							<input type="text" id="maintTime" name="maintTime"
								class="spare-add-input" />
						</div>
					</li>
					<li>
						<div class="spare-addl">单位：</div>
						<div class="spare-addr">
							<input type="text" class="spare-add-input" id="maintUnit"
								name="maintUnit" />
						</div>
					</li>
					<li>
						<div class="spare-addl">更换部件：</div>
						<div class="spare-addr">
							<input type="text" class="spare-add-input" id="replacePart"
								name="replacePart" />
						</div>
					</li>
					<li>
						<div class="spare-addl">维修人员：</div>
						<div class="spare-addr">
							<input type="text" class="spare-add-input" id="maintPerson"
								name="maintPerson" />
						</div>
					</li>
					<li>
						<div class="spare-addl">验收人员：</div>
						<div class="spare-addr">
							<input type="text" class="spare-add-input" id="acceptPerson"
								name="acceptPerson" />
						</div>
					</li>
					<li>
						<div class="spare-addl">备注：</div>
						<div class="spare-addr">
							<textarea class="spare-add-textarea" id="maintRemark"
								name="maintRemark"></textarea>
						</div>
					</li>
				</ul>


			</form>

		</div>
	</div>
</body>

<script th:inline="javascript">  
/*<![CDATA[*/  
  var Mr ;
  function verifyNull(obj){
	
		if(obj == null||obj.val()==""||obj.val()=="请选择"){
			top.$.Zebra_Dialog('<div class="prompt"><div class="warning-icon"></div><div class="success-title">输入的内容不能包含空</div></div>', {
				'title':'提示',
	 	         'buttons':['确定']
		     });
			return false;
		}
	return true;
}      
 function getData(){
	if(!verifyNull($("#recordNo"))){
 		return false;
 	}
	return true;
 }
	//选择一条维修计划
	function selectPlan(){
		var data= getDataJson("userGroupForm");
		$.extend(Mr, data);
		$.get("/zbdzll-rw", data,function(result){
			$("body").html(result);
		  });
		
	}      
 
 function Save(){
		var validate=getData();
		  if(!validate){
			 return false;
		 }
	   var data= getDataJson("userGroupForm");
      AjaxWebTableInfo("/wxjl/saveOrUpdate",data);
	 }
	      
	function AjaxWebTableInfo(url , obj){
		 $.ajax({
		     type: "post",
		     dataType: "json",
		     url: url,
		     data:obj,
		     success: function (data, status) {
		    	 		$.Zebra_Dialog(
								'<div class="prompt"><div class="success-icon"></div><div class="success-title">保存成功</div></div>',
								{
									'title' : '提示',
									'show_close_button' : false,
									'buttons' : [ {
										caption : '确定',
										callback : function() {
												loadPage("/wxjl");
										}
									} ]
								});
		     },
		     error: function (data) {
		    	 $.Zebra_Dialog('<div class="prompt"><div class="error-icon"></div><div class="success-title">保存失败!</div></div>', {
			            'title':'提示',
			            'buttons':['确定']
			         });
		     }
		 });	
	}
 
//加载数据
$(function() { 
    Mr = [[${Mr}]];  
    if(Mr!=null){
        loadData(Mr);
    }
});
    
/*]]>*/  
</script>

</html>
